How to convert this example of nested ternary if-else to if-else loop

welcome to shbcf.ru